﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MaBlaApp.Data;

/// <summary>
/// 语言帮助类
/// </summary>
public static class LangHelper
{
    /// <summary>
    /// 软件当前的语言
    /// </summary>
    public static string CurrentLang
    {
        get => Preferences.Get(nameof(CurrentLang), "en-US");
        set => Preferences.Set(nameof(CurrentLang), value);
    }

    /// <summary>
    /// 软件支持的语言
    /// </summary>
    public static string[] SupportLangs = new string[] { "en-US", "zh-CN", };

    /// <summary>
    /// 设置软件语言
    /// </summary>
    public static void SetCurrentLang(string lang)
    {
        var cultureInfo = new CultureInfo(lang);

        //影响razor页面字符串
        CultureInfo.CurrentCulture = cultureInfo;

        //影响类库字符串
        CultureInfo.CurrentUICulture = cultureInfo;

        System.Diagnostics.Debug.WriteLine($"{DateTimeOffset.Now}, 设置软件语言{lang}");
    }
}
